import { ref} from "vue";
import axios from 'axios';
import { routerStore } from "@/stores/counter";
export const useData=()=>{

   let showCheck1 = ref(false);
   let showCheck2 = ref(false);
   let way = ref(true);
    function toggleCheck1() {
      showCheck1.value= !showCheck1.value;
      console.log(showCheck1.value)
    }
    function toggleCheck2() {
      showCheck2.value= !showCheck2.value;
      console.log(showCheck2.value)
    }
    function wayFalse() {
      way.value= false;
      console.log(way)
    }
    function wayTrue() {
      way.value= true;
      console.log(way)
    }
    
    return{showCheck1,showCheck2,way,
      toggleCheck1,toggleCheck2,wayFalse,wayTrue}
}

export const loginData = () => {
  const password = ref('');
  const mobile = ref('');
  const r=routerStore();
  const Login = () => {
    const data = {
      password: password.value,
      mobile: mobile.value,
    };

    axios.post('http://127.0.0.1:8888/login/page', data)
      .then(response => {
        console.log(response.data);
        alert('登录成功！');
      })
      .catch(error => {
        console.error(error);
        alert('登录失败')
      });
  };
  
  return { password, mobile, Login ,r};
};